<script setup lang="ts">
import type {PlayMoreAction, SongInfo} from '@/types/Playing'
import {ref} from 'vue'
const emit = defineEmits(['onPlaySort','onCell','onChange','onHeaderItem'])
const props = defineProps<{
  actions:PlayMoreAction[],
  songs:SongInfo[]
}>()
console.log(props.songs)
const rotation = ref(0)
const onChange = ()=>{
  rotation.value += 180
  emit('onChange')
}

</script>

<template>
  <div class="header">
    <div class="item" v-for="item in props.actions" :key="item.id" @click="emit('onHeaderItem',item)">
          <div class="img iconfont" :class="item.icon"></div>
          <div class="txt">{{ item.name }}</div>
      </div>
  </div>

  <div class="list-header">
    <div class="left">
      播放列表
    </div>
    <div class="right">
      <div class="content-txt" @click="onChange">
        <span class="iconfont icon-shuaxin icon" :style="{ transform: `rotate(${rotation}deg)` }"></span>
        换一批
      </div>
      <div class="content-txt" style="margin-left: 4vw;" @click="emit('onPlaySort')">
        <span class="iconfont icon-shuaxin icon" ></span>
        顺序播放
      </div>
    </div>
  </div>

  <div class="list">
    <div class="cell" v-for="song in songs" :key="song.cover" @click="emit('onCell',song)">
        <div class="image" :style="{ backgroundImage: `url(${song.cover})`}">

        </div>
        <div class="song-info">
          <div class="song-name">
            {{ song.name }}
          </div>
          <div class="song-author">
            {{ song.lyric }} ~ {{ song.pop }}
          </div>
        </div>
    </div>
  </div>

  <div class="footer">
    听得越多,推荐越多
  </div>
</template>

<style lang="scss" scoped>
.header {
  background-color: transparent;
  width: 100%;
  height: 30vw;
  display: flex;
  flex-wrap: nowrap;
  overflow: auto;
  justify-content: flex-start;
  padding-left: 4vw;
  padding-top: 6vw;
}
.item {
  width: 20vw;
  height: 24vw;
  background-color: #333;
  margin-bottom: 3vw;
  margin-right: 4vw;
}
.img {
  width: 16vw;
  border-radius: 10vw;
  height: 16vw;
  margin-left: 2vw;
  background-color: #666;
  font-size: 10vw;
  line-height: 16vw;
  text-align: center;
}
.txt {
  color: #666;
  font-size: 2.5vw;
  text-align: center;
  background-color: transparent;
  margin-top: 2vw;
}

.list-header {
  display: flex;
  height: 14vw;
  width: 100%;
  background-color: transparent;
  padding: 0 4vw;
  border-top: 1px solid #666;
  align-items: center;
  justify-content: space-between;
}
.left {
  color: #fff;
  font-size: 5vw;
  background-color: transparent;
}

.right {
  display: flex;
  justify-content: flex-end;
  align-content: center;
  background-color: transparent;
}

.content-txt {
  color: #999;
  font-size: 4vw;
  line-height: 100%;
  line-height: 13vw;
  text-align: center;
  background-color: transparent;
}
.icon {
  display: inline-block;
  color: #fff;
  font-size: 4vw;
  line-height: 13vw;
  transition: transform 0.3s ease;
  /* 添加过渡效果 */
  cursor: pointer; // 鼠标效果
  background-color: transparent;
}

.footer {
  color: #999;
  background-color: transparent;
  text-align: center;
  width: 100%;
  height: 15vw;
  font-size: 4vw;
  line-height: 15vw;
}

.list {
  padding: 0 4vw;
  background-color: transparent;
}
.cell {
  height: 20vw;
  width: 100%;
  background-color: transparent;
  margin-bottom: 3vw;
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-start;
}

.image {
  background-color: transparent;
  width: 15vw;
  height: 100%;
  background-size: cover;
  margin-right: 3vw;
}

.song-info {
  background-color: transparent;
  display: flex;
  justify-content: center;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  row-gap: 2vw;
}

.song-name {
  background-color: transparent;
  color: #f0f0f0;
  font-size: 4vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis; /* 如果文本溢出，使用省略号表示 */
}
.song-author {
  background-color: transparent;
  color: #aaa;
  font-size: 4vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis; /* 如果文本溢出，使用省略号表示 */
}
</style>